package com.kuaidi100.sdk.contant;

public enum ExpressState {

    // 揽收相关
    PICKUP(1, "揽收"),
    ORDER_PLACED(101, "已下单"),
    WAITING_FOR_PICKUP(102, "待揽收"),
    PICKED_UP(103, "已揽收"),

    // 在途相关
    IN_TRANSIT(0, "在途"),
    ARRIVED_CITY(1001, "到达派件城市"),
    TRUNK_LINE(1002, "干线"),
    TRANSFER(1003, "转递"),

    // 派件相关
    DELIVERING(5, "派件"),
    DELIVERY_TO_CABINET_OR_STATION(501, "投柜或驿站"),

    // 签收相关
    SIGNED(3, "签收"),
    SELF_SIGNED(301, "本人签收"),
    DELIVERY_EXCEPTION_SIGNED(302, "派件异常后签收"),
    SIGNED_BY_OTHER(303, "代签"),
    CABINET_OR_STATION_SIGNED(304, "投柜或站签收"),

    // 退回相关
    RETURNED(6, "退回"),
    RETURN_SIGN(4, "退签"),
    CANCELED(401, "已销单"),

    // 拒签相关
    REJECTED(14, "拒签"),

    // 转投相关
    TRANSFER_DELIVERY(7, "转投"),

    // 疑难件相关
    DIFFICULT(2, "疑难"),
    NOT_SIGNED_TIMEOUT(201, "超时未签收"),
    NO_UPDATE_TIMEOUT(202, "超时未更新"),
    REFUSED(203, "拒收"),
    DELIVERY_EXCEPTION(204, "派件异常"),
    CABINET_TIMEOUT(205, "柜或驿站超时未取"),
    UNREACHABLE(206, "无法联系"),
    OUT_OF_AREA(207, "超区"),
    STUCK(208, "滞留"),
    DAMAGED(209, "破损"),
    CANCELED_MANUALLY(210, "销单"),

    // 清关相关
    CUSTOMS_CLEARANCE(8, "清关"),
    WAITING_CUSTOMS(10, "待清关"),
    CUSTOMS_PROCESSING(11, "清关中"),
    CUSTOMS_CLEARED(12, "已清关"),
    CUSTOMS_EXCEPTION(13, "清关异常");

    private final int code;
    private final String description;

    ExpressState(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static ExpressState fromCode(int code) {
        for (ExpressState status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}